﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GamePlugin.Logics.Core;
using WindowsInput;
using System.Drawing;
using GamePlugin.Logics.Data.Auction;
using GamePlugin.IO;

namespace GamePlugin.Logics.Game.Actions
{
    public class DActionAuctionReceiveItems : MachineState
    {
        public override void Initialize()
        {
            this.AddState("ReceiveItems");
            this["ReceiveItems"].UpdateEvent += new EventHandler<GameTimeEventArgs>((o, e) => this.ReceiveItems(o, e));

            this.AddState("Finished");
            this["Finished"].UpdateEvent += new EventHandler<GameTimeEventArgs>((o, e) => this.Finished(o, e));

            this.DefaultState = "ReceiveItems";
        }

        public void ReceiveItems(object o, GameTimeEventArgs e)
        {
            InputSimulator input = Workspace.Instance.DiabloPluginGame.InputSimulator;

            Helper.MoveCursor(ActionData.PageFinishedPoint);
            Helper.Sleep(100);
            input.Mouse.LeftButtonClick();
            Helper.Sleep(100);

            Helper.MoveCursor(530, 450);
            Helper.Sleep(100);
            input.Mouse.LeftButtonClick();
            Helper.Sleep(100);

            for (int i = 0; i < 10; i++)
            {
                input.Mouse.LeftButtonClick();
                Helper.Sleep(100);
            }

            this.ChangeToState("Finished");
        }

        public void Finished(object o, GameTimeEventArgs e)
        {
            InputSimulator input = Workspace.Instance.DiabloPluginGame.InputSimulator;

            this.Owner.ChangeToState(typeof(DActionAuctionStart).Name);
        }
    }
}
